package kr.pe.johnkim.waiting.mobile.dao;

import kr.pe.johnkim.waiting.mobile.domain.WaitingMemberRecommendation;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 7. 15.
 */
@Repository
public class WaitingMemberRecommendationDaoImpl extends SqlSessionDaoSupport implements WaitingMemberRecommendationDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(WaitingMemberRecommendationDaoImpl.class);

    /**
     * 사용자의 추천 중복을 확인 한다.
     *
     * @param waitingMemberRecommendation
     * @return
     */
    @Override
    public WaitingMemberRecommendation selectDuplicationMemberRecommendation(WaitingMemberRecommendation waitingMemberRecommendation) {
        logger.info("selectDuplicationMemberRecommendation");
        return (WaitingMemberRecommendation)this.getSqlSession().selectOne("WAITING_MEMBER_RECOMMENDATION.selectDuplicationMemberRecommendation", waitingMemberRecommendation);
    }

    /**
     * 사용자의 추천을 등록 한다.
     *
     * @param waitingMemberRecommendation
     */
    @Override
    public void registerMemberRecommendation(WaitingMemberRecommendation waitingMemberRecommendation) {
        logger.info("registerMemberRecommendation");
        this.getSqlSession().insert("WAITING_MEMBER_RECOMMENDATION.registerMemberRecommendation", waitingMemberRecommendation);
    }

    /**
     * 사용자의 추천을 비활성화 한다.
     *
     * @param waitingMemberRecommendation
     */
    @Override
    public void updateDeactivateMemberRecommendation(WaitingMemberRecommendation waitingMemberRecommendation) {
        logger.info("updateDeactivateMemberRecommendation");
        this.getSqlSession().update("WAITING_MEMBER_RECOMMENDATION.updateDeactivateMemberRecommendation", waitingMemberRecommendation);
    }

    /**
     * 특정 사용자의 추천 목록을 가져 온다.
     *
     * @param waitingMemberRecommendation
     * @return
     */
    @Override
    public List<WaitingMemberRecommendation> selectMemberRecommendationList(WaitingMemberRecommendation waitingMemberRecommendation) {
        logger.info("selectMemberRecommendationList");
        return this.getSqlSession().selectList("WAITING_MEMBER_RECOMMENDATION.selectMemberRecommendationList", waitingMemberRecommendation);
    }

    /**
     * 특정 가맹점에 대한 사용자 추천 목록을 가져 온다.
     *
     * @param waitingMemberRecommendation
     * @return
     */
    @Override
    public List<WaitingMemberRecommendation> selectMerchantRecommendationList(WaitingMemberRecommendation waitingMemberRecommendation) {
        logger.info("selectMerchantRecommendationList");
        return this.getSqlSession().selectList("WAITING_MEMBER_RECOMMENDATION.selectMerchantRecommendationList", waitingMemberRecommendation);
    }
}
